package com.king.designpatterns.创造型模式.单例模式;

/**
 * 懒汉式单例类
 *
 * @author king
 * @date 2021-06-04 23:59
 */
public class LazySingleton {
    private static LazySingleton _instance = null;
    // 构造方法私有，保证外界无法直接实例化
    private LazySingleton(){}

    // 方法同步
    synchronized public static LazySingleton getInstance(){
        if (_instance == null){
            _instance = new LazySingleton();
        }
        return _instance;
    }
}
